<?php


namespace app\cms\dto\basic;


class dataBasic {

    public int $update_time;
    public int $create_time;

    public mixed $uid;

    /**
     * 获取用户id
     * @param bool $getSession
     * @return int|null
     * @throws \Exception
     */
    public function getUid(bool $getSession = true): int|null {

        $this->uid = session('userInfo', callable: function ($info) {
            $userinfo = is_string($info) ? (
                json_decode($info, JSON_UNESCAPED_UNICODE) ?: []
            ) : $info;
            return $userinfo['uid'];
        });

        return $this->uid;
    }

    /**
     * @param mixed $uid
     */
    public function setUid(mixed $uid): void
    {
        $this->uid = $uid;
    }

    /**
     * 获取创建时间
     * @return int
     */
    public function getCreateTime(): int
    {
        return $this->create_time;
    }

    /**
     * 获取更新时间
     * @return int
     */
    public function getUpdateTime(): int
    {
        return $this->update_time;
    }

    /**
     * 设置创建时间
     * @param int $update_time
     */
    public function setUpdateTime(int $update_time): void
    {
        $this->update_time = $update_time;
    }

    /**
     * 设置更新时间
     * @param int $create_time
     */
    public function setCreateTime(int $create_time): void
    {
        $this->create_time = $create_time;
    }

}